<template>
  <div>
    <el-form inline :model="queryData" ref="queryData" class="query-form">
      <el-form-item label="类型:" prop="type">
        <el-select v-model="queryData.type" placeholder="请选择" clearable @clear="formClear('type')"
                   style="width: 200px">
          <el-option label="电商代运营" value="0"/>
          <el-option label="新媒体代运营" value="1"/>
        </el-select>
      </el-form-item>

      <!-- <el-form-item label="分类:" prop="type">
        <el-select v-model="queryData.type" placeholder="请选择" style="width: 100%" clearable @clear="formClear('type')">
          <el-option :label="item.name" :value="item.code - 0" v-for="(item, index) in typeList" :key="index"/>
        </el-select>
      </el-form-item> -->

      <el-form-item>
        <el-button type="primary" @click="onSubmit">查 询</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="tableList" border style="width: 100%;">
      <el-table-column type="index" label="序号" align="center" width="80"/>
      <el-table-column prop="createTime" label="创建时间" align="center" width="150">
          <template slot-scope="{row}">
              {{row.createTime | FormDataTime }}
          </template>
      </el-table-column>
      <el-table-column prop="titleOne" label="电商平台产品经销渠道" align="center"/>
      <el-table-column prop="titleTwo" label="经销渠道销售额与营销费用" align="center"/>
      <el-table-column prop="titleThree" label="线下渠道产品销售额与营销费用" align="center"  show-overflow-tooltip/>
      <el-table-column prop="titleFour" label="营收目标与营销费用预算" align="center" show-overflow-tooltip/>
      <el-table-column prop="titleFive" label="企业与产品介绍" align="center"/>
      <el-table-column label="类型" align="center" width="100">
        <template slot-scope="{row}">
          <span v-if="row.type==0">电商代运营</span>
          <span v-if="row.type==1">新媒体代运营</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="150" fixed="right">
        <template slot-scope="{row}">
          <el-button type="text" @click="deleteEvent(row)">删 除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <Paging v-model="queryData" @change="getRequest"></Paging>
  </div>
</template>

<script>
import {mapGetters} from "vuex";

export default {
  computed: {
    ...mapGetters(['confirm'])
  },
  name: 'onlineRetailers',
  filters:{
      FormDataTime(value){
          return value.slice(0,10)
      }
  },
  data() {
    return {
      tableList: [],
      typeList: [],
      queryData: {
        type: null, // 类型资源表code
        pageNum: 1,
        pageSize: 10,
        total: 0
      },
      entity: null,
      drawer: false
    }
  },
  beforeMount() {
    this.getRequest()
  },
  methods: {
    /**
     * 删除事件
     */
    deleteEvent(row) {
        let params={
            ids:row.id
        }
        
        this.$confirm(this.confirm.text, '提示', this.confirm.options).then(async () => {
          await this.$ajax.post(`/enterpriseserve/er/remove`,params).then(res=>{
              this.getRequest();
          })
          this.getRequest()
        })
    },
      /**
     * 查询条件提交事件
     */
    onSubmit() {
      this.queryData.pageNum = 1
      this.getRequest()
    },
    //置空事件
    formClear(key) {
      this.queryData[key] = null
      this.onSubmit()
    },
    /**
     * 重置事件
     */
    onReset() {
      this.queryData.pageNum = 1
      this.$refs['queryData'].resetFields()
      this.getRequest()
    },
    /**
     * 列表请求事件
     */
    async getRequest() {
      const params = JSON.parse(JSON.stringify(this.queryData))
      const res = await this.$ajax.get('/enterpriseserve/er/backstage/list', {params})
      this.queryData.total = res.total
      this.tableList = res.rows
    },
  }
}
</script>

<style scoped>

</style>
